package com.lxc.ms.controller;

import com.lxc.ms.dto.FenpaiDto;
import com.lxc.ms.dto.OrderPageDto;
import com.lxc.ms.entity.MsOrder;
import com.lxc.ms.result.PageResult;
import com.lxc.ms.result.Result;
import com.lxc.ms.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 功能:
 * 作者: lxc
 * 日期: 2024/8/28 15:56
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/save")
    public Result save(@RequestBody MsOrder msOrder){
        log.info("添加的工单:{}", msOrder);
        orderService.save(msOrder);
        return Result.success();
    }
    @PostMapping("/delete")
    public Result delete(@RequestParam Long id){
        orderService.delete(id);
        return Result.success();
    }

    @PostMapping("/update")
    public Result update(@RequestBody MsOrder msOrder){
        orderService.update(msOrder);
        return Result.success();
    }

    @PostMapping("/search")
    public Result<PageResult> search(OrderPageDto orderPageDto){
        PageResult pageResult = orderService.search(orderPageDto);
        return Result.success(pageResult);
    }

    @PostMapping("/fenpai")
    public Result fenpai(@RequestBody FenpaiDto fenpaiDto){
        orderService.fenpai(fenpaiDto);
        return Result.success();
    }
}
